home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Essentials / MacApp Documentation / MacApp AppleLink Messages / MacApp.Tech$ 12⁄1⁄89 / 0401-cmd-period-Jan90 < prev    next >
Encoding:
Text File  |  1990-01-12  |  1.8 KB  |  76 lines  |  [TEXT/GEOL]

  1. Item    1071028                         11-Jan-90        13:28
  2.  
  3. From:   J.HARVEY                        Harvey, John
  4.  
  5. To:     D5369                           Mgmt Sys Des, Chuck McMath,PRT
  6.  
  7. cc:     MACAPP.TECH$                    MacApp Technical
  8.  
  9. Sub:    cmd-period
  10.  
  11. Chuck,
  12.  
  13. The code below will do the right think international wise as far as checking
  14. for a command period.  You need to strip out the command key to check and see
  15. if a period was pressed since command hides the fact that a period was pressed
  16. on systems where shift-somekey is necessary to produce a period (italian for
  17. one).
  18.  
  19. John Harvey
  20. MacDTS
  21.  
  22. CONST
  23.    kMaskModifier = 0xFE00; {need to stript command key from Modifiers}
  24.    kMaskVirtualKey = 0x0000FF00; {get virtual key from event message}
  25.    kMaskASCII1 = 0x000000FF; {get key from KeyTrans return}
  26.    kPeriod = ORD('.');
  27.  
  28. TYPE
  29.    EventPtr = ^EventRecord;
  30.  
  31. FUNCTION CmdPeriod(theEvent: EventPtr): Boolean;
  32. VAR
  33.    keyCode :   Integer;
  34.    virtualKey,
  35.    keyInfo,
  36.    theChar,
  37.    state,
  38.    keyCId  :   Longint;
  39.    hKCHR   :   Handle;
  40.  
  41. BEGIN
  42.  
  43.    CmdPeriod   := FALSE;
  44.  
  45.    IF ( theEvent^.what = keyDown || theEvent^.what = autoKey) THEN BEGIN
  46.  
  47.    {see if the command key is down.  If it is, get the ASCII }
  48.  
  49.    IF ( BAND(theEvent^.modifiers,cmdKey) <> 0 ) THEN BEGIN
  50.  
  51.    virtualKey := BAND(theEvent^.message,kMaskVirtualKey) DIV 256;
  52.    keyCode := BAND(theEvent^.modifiers,kMaskModifiers) + virtualKey+btnState;
  53.    state := 0;
  54.  
  55.    keyCId := GetScript( GetEnvirons(smKeyScript), smScriptKeys);
  56.  
  57.    {read the appropriate KCHR resource }
  58.    hKCHR := GetResource('KCHR',keyCId);
  59.  
  60.    IF (hKCHR <> NIL) THEN BEGIN
  61.    HLock(hKCHR);
  62.    keyInfo := KeyTrans(hKCHR^,keyCode,state);
  63.    HUnlock(hKCHR);
  64.    ReleaseResource(hKCHR);
  65.  
  66.    theChar := BAND(keyInfo,kMaskASCII1);
  67.  
  68.    IF ( theChar = kPeriod)
  69.    CmdPeriod := TRUE;
  70.    END;
  71.    END;
  72.    END;
  73.  
  74. END;
  75.  
  76.